package com.xiaocg.link;

public abstract class Handler {
    public static final Integer NUM1 =1;
    public static final Integer NUM2 =3;
    public static final Integer NUM3 =7;
    private Integer start;
    private Integer end;

    private Handler nextHandler;

    public Handler(Integer start) {
        this.start = start;
    }

    public Handler(Integer start, Integer end) {
        this.start = start;
        this.end = end;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    protected abstract void handleRequest(LeaveRequest request);

    public final void  commitNextHandler(LeaveRequest request){
        handleRequest(request);
        if (this.nextHandler!=null && request.getNum()> this.end){
            this.nextHandler.commitNextHandler(request);
        }else {
            System.out.println("已经完成");
        }
    }
}
